<?php
class CompanyPersonContactPositionsFForm extends BaseFormAdmin{
	public function configure(){
		$this->setWidgets(array(
				'name'        			=> new sfWidgetFormInputText(),
				'job_position_id'		=> new sfWidgetFormDoctrineChoice(array(
						'model' 			=> 'JobPositions',
						'query'				=> Doctrine_Query::create()
						->select('b.id, b.name')
						->from('JobPositions b')
						->where('b.is_enabled = 1 AND b.is_deleted = 0 AND (b.updated_at IS NULL OR b.updated_at >= b.created_at)')
						->orderBy('b.name asc'),
						'multiple'	=> false,
						'add_empty' => __('option_select', null, 'table_list'))),
				'description' => new sfWidgetFormTextarea(),				
		));

		$this->setValidators(array(
				'name'        => new sfValidatorString(array('max_length' => 255, 'required' => true)),
				'job_position_id'			=> new sfValidatorDoctrineChoice(array('model' => 'JobPositions', 'query' => Doctrine_Query::create()->select('b.id, b.name')->from('JobPositions b')->where('b.is_enabled = 1 AND b.is_deleted = 0 AND (b.updated_at IS NULL OR b.updated_at >= b.created_at)'), 'required' => true),array()),
				
				'description' => new sfValidatorString(array('required' => false)),
				
		));
		
		parent::configure();
		
		/*
		 * Setting name of form
		*/
		$this->widgetSchema->setNameFormat('CompanyPersonContactPositions[%s]');
		$this->errorSchema = new sfValidatorErrorSchema($this->validatorSchema);
	}
	
}
